package gold.digger;

import gold.utils.InputUtil;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1614 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maxDepth(String s) {
            int maxDepth = 0, curLeftCounter = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '(') maxDepth = Math.max(maxDepth, ++curLeftCounter);
                else if (s.charAt(i) == ')') --curLeftCounter;
            }

            return maxDepth;
        }
    }

    public void run() {
        Solution solution = new Solution();

//        输入：s = "(1+(2*3)+((8)/4))+1"
//        输出：3
//        解释：数字 8 在嵌套的 3 层括号中。
        System.out.println(solution.maxDepth("(1+(2*3)+((8)/4))+1"));

//        输入：s = "(1)+((2))+(((3)))"
//        输出：3
        System.out.println(solution.maxDepth("(1)+((2))+(((3)))"));
    }

    public static void main(String[] args) throws Exception {
        LC1614 an = new LC1614();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
